import * as BASE from '@/stores/definitions-base';
import { Input } from '@alifd/next';
import { t } from '@lingui/macro';
import React from 'react';

const {
  DATETIME_TEXT,
  DATE_TEXT,
  TIME_TEXT,
  EMPTY_TEXT,
  ENUMS: ENUMSBase,
  FieldsGrid: FieldGridBase,
  TitleGrid,
  column: columnBase,
  toSelectDataSource,
} = BASE;
export { DATETIME_TEXT, DATE_TEXT, EMPTY_TEXT, TIME_TEXT, TitleGrid, toSelectDataSource };

export function column(...args) {
  return columnBase(orderModel, ...args);
}

export function FieldsGrid(props) {
  return <FieldGridBase model={orderModel} {...props} />;
}

//----------------------------------------------------------------------
export const ENUMS = {
  ...ENUMSBase,
};

export const orderModel = {
  driverInfo: {
    label: t`司机信息`,
    companyId: {
      label: t`公司id`,
    },
    auditStatus: {
      label: t`审核状态是否通过`,
    },
    driverStatus: {
      label: t`司机状态 1-启用、0-停用，控制台设置`,
    },
    dutyStatus: {
      label: t`值班状态 1-正常在岗、0-离岗休假，司机可自行设置，离岗后，将不派单给该司机`,
    },
    dutyVehicleId: {
      label: t`值班车辆 正常在岗时，司机可自行选择关联的车辆，也可以后台设置`,
    },
    dateBirth: {
      label: t`出生年月`,
    },
    permanentLand: {
      label: t`常驻地`,
    },
    licenseMainland: {
      label: t`大陆驾驶证信息`,
      licenseNo: {
        label: t`驾驶证号`,
      },
      vechileType: {
        label: t`驾驶车型 选择，大型客车、中型客车、小型客车、大型货车`,
      },
      validityDate: {
        label: t`驾驶证有效期 输入了驾驶证号，就是必填`,
      },
    },
    licenseHK: {
      label: t`香港驾驶证信息`,
      licenseNo: {
        label: t`驾驶证号`,
      },
      vechileType: {
        label: t`驾驶车型 选择，大型客车、中型客车、小型客车、大型货车`,
      },
      validityDate: {
        label: t`驾驶证有效期 输入了驾驶证号，就是必填`,
      },
    },
    internationalLicense: {
      label: t`国际驾照 选择，无（默认）、 大型客车、中型客车、小型客车、大型货车`,
    },
    attachments: [
      {
        label: t`附件`,
        title: {
          label: t`附件标题`,
        },
        description: {
          label: t`附件说明`,
        },
        binaryId: [
          {
            label: t`附件id`,
          },
        ],
      },
    ],
    registerTime: {
      label: t`注册时间`,
    },
    hkMobile: {
      label: t`香港电话`,
    },
    number: {
      label: t`身份证号`,
    },
    address: {
      label: t`住址`,
    },
    type: {
      label: t`1商务车司机 2巴士司机`,
    },
    independentAccount: {
      label: t`分账设置信息`,
      period: {
        label: t`分账周期：T+0、T+1、T+2、T+7、T+30(加几值为几，例：T+0 值为0)`,
      },
      suspensionOfDistribution: {
        label: t`暂停分账 true：暂停 false：可分账`,
      },
      settlementOfDriverCharges: {
        label: t`是否委托平台自动结算司机费用`,
      },
      collectionAccountInformation: {
        label: t`收款账户信息`,
        appId: {
          label: t`公众号appId`,
        },
        accountIdentification: {
          label: t`账户标识`,
        },
        name: {
          label: t`名字`,
        },
        type: {
          label: t`分账接收方类型<br/> MERCHANT_ID：商户号<br/> PERSONAL_OPENID：个人openid`,
        },
      },
    },
  },
  company: {
    label: t`公司信息`,
    code: {
      label: t`公司id<br/> 2位注册地区编码+4位数字<br/> - 香港HK<br/> - 大陆CN<br/> - 澳门OM`,
    },
    name: {
      label: t`公司名称`,
    },
    registerAddr: {
      label: t`注册地区<br/> - 香港HK<br/> - 大陆CN<br/> - 澳门OM`,
    },
    tel: {
      label: t`公司电话`,
    },
    address: {
      label: t`联系地址`,
    },
    independentAccount: {
      label: t`分账设置信息`,
      period: {
        label: t`分账周期：T+0、T+1、T+2、T+7、T+30(加几值为几，例：T+0 值为0)`,
      },
      suspensionOfDistribution: {
        label: t`暂停分账 true：暂停 false：可分账`,
      },
      settlementOfDriverCharges: {
        label: t`是否委托平台自动结算司机费用`,
      },
      collectionAccountInformation: {
        label: t`收款账户信息`,
        appId: {
          label: t`公众号appId`,
        },
        accountIdentification: {
          label: t`账户标识`,
        },
        name: {
          label: t`名字`,
        },
        type: {
          label: t`分账接收方类型<br/> MERCHANT_ID：商户号<br/> PERSONAL_OPENID：个人openid`,
        },
      },
    },
    orgCode: {
      label: t`工商编码`,
    },
    isManual: {
      label: t`手工派单<br/> - false 自动<br/> - true 手工`,
    },
    orgDirector: {
      label: t`企业负责人<br/> 必填，法人代表等`,
    },
    directorIdType: {
      label: t`负责人证件类型`,
    },
    directorId: {
      label: t`负责人证件号`,
    },
    directorTel: {
      label: t`负责人电话`,
    },
    dateOfIncorporate: {
      label: t`成立日期`,
    },
    status: {
      label: t`公司状态<br/> 必填<br/> - 1 启用（默认）<br/> - 0 禁用 禁用时，不派单给该公司旗下车辆`,
    },
    bankAccounts: {
      label: t`开户行信息`,
      bank: {
        label: t`开户银行 下拉选择`,
      },
      accountName: {
        label: t`账户名称`,
      },
      account: {
        label: t`银行账号`,
      },
    },
  },
  hasSurcharge: {
    label: t`是否设置运营附加费<br/> - true 已设置，<br/> - false 未设置`,
  },
  attachments: [
    {
      label: t`附件`,
      title: {
        label: t`附件标题`,
      },
      description: {
        label: t`附件说明`,
      },
      binaryId: [
        {
          label: t`附件id`,
        },
      ],
    },
  ],
  crBy: {
    label: t`创建者`,
  },
  upBy: {
    label: t`最后修改者`,
  },
  crDate: {
    label: t`创建时间`,
  },
  upDate: {
    label: t`最后修收时间`,
  },
  tenantId: {
    label: t`租户ID`,
  },
  operating: {
    label: t``,
  },
  vehicleTypeName: {
    label: t`车型`,
  },
  brandModelName: {
    label: t`车牌名称`,
  },
  permanentLandName: {
    label: t`车辆常驻地`,
  },
  mainDriverName: {
    label: t`主司机`,
  },
  coDriverNames: {
    label: t`副司机`,
  },
  ccOrderNum: {
    label: t`专车数量`,
  },
  portNames: {
    label: t`口岸`,
  },
  username: {
    label: t`用户标识`,
  },
  fullname: {
    label: t`司机`,
  },
  phone: {
    label: t`该司机的手机号`,
  },
  isService: {
    label: t`是否正在服务中`,
  },
  isConnect: {
    label: t`是否存在值班车辆是该车的司机用户`,
  },
  code: {
    label: t`车辆编号 自动生成，公司编码+四位数字`,
  },
  companyId: {
    label: t`公司编码`,
  },
  type: {
    label: t`商务车1，巴士2`,
  },
  vin: {
    label: t`VIN码`,
  },
  landCompany: {
    label: t`大陆公司`,
  },
  hkCompany: {
    label: t`香港公司`,
  },
  vehicleColor: {
    label: t`车辆颜色`,
  },
  engine: {
    label: t`发动机号`,
  },
  firstTime: {
    label: t`首次登记时间`,
  },
  manufacturer: {
    label: t`生产商`,
  },
  licenseNo: {
    label: t`车辆号牌`,
    mainland: {
      label: t`大陆号牌`,
    },
    hk: {
      label: t`香港号牌`,
    },
  },
  vehicle: {
    label: t`品牌型号 选择`,
  },
  vehicleType: {
    label: t`车辆类型 1-大巴 2-商务车 3-小客车`,
  },
  numberOfSeats: {
    label: t`座位数`,
  },
  dateOfDelivery: {
    label: t`出厂日期`,
  },
  remark: {
    label: t`派单备注`,
    ui_edit: {
      renderer: () => <Input.TextArea />,
      span: 4,
    },
  },
  status: {
    label: t`车辆状态 0-停用（默认）;1-启用，停用时不派单`,
  },
  validityDateOfAnnualReview: {
    label: t`年审有效期`,
  },
  validityDateOfEntryExit: {
    label: t`出入境有效期`,
  },
  permanentLand: {
    label: t`常驻地`,
  },
  carType: {
    label: t`汽车类型：营运车，其他车（蓝牌）`,
  },
  ports: [
    {
      label: t`出入口岸`,
    },
  ],
  mainDriver: {
    label: t`主司机`,
  },
  coDrivers: [
    {
      label: t`关联司机标识（副司机）`,
    },
  ],
  tude: {
    label: t`经纬度`,
  },
  address: {
    label: t`地址`,
  },
  // 前端新增字段
  showCar: {
    label: t`承运车辆`,
    text: (_, record) => {
      const { mainland, hk } = record?.licenseNo;
      return `${mainland}(${hk})`;
    },
    ui_view: {
      renderer: (_, record) => {
        const { mainland, hk } = record?.licenseNo;
        return `${mainland}/${hk}`;
      },
      span: 2,
    },
  },
  showDriver: {
    label: t`承运司机`,
    ui_view: {
      renderer: (_, record) => {
        const { fullname, phone } = record;
        return `${fullname} ${phone}`;
      },
      span: 2,
    },
  },
  sendCarOrderPrice: {
    label: t`派单价格`,
    ui_view: {
      renderer: (_, record) => {
        const { carrierPrice } = record?.taskInfo;
        return `¥${carrierPrice}`;
      },
      span: 4,
    },
  },
  orderRemark: {
    label: t`订单备注`,
    ui_view: {
      renderer: (_, record) => {
        const { remarks } = record?.orderInfo?.ccOrder;
        return <span style={{ color: 'red' }}>{remarks || '无'}</span>;
      },
      span: 4,
    },
  },
  driverServiceFee: {
    label: t`司机费用`,
    ui_edit: {
      span: 4,
      itemProps: { required: true },
    },
  },
};
